<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>login</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.6 -->
  <link rel="stylesheet" href="${path}/resource/plugins/bootstrap/css/bootstrap.min.css">
 
  <!-- base -->
  <link rel="stylesheet" href="${path}/resource/css/base.css">
 
  <!-- main -->
  <link rel="stylesheet" href="${path}/resource/css/ysrmain.css">
  <link rel="stylesheet" href="${path}/resource/css/main.css">
  
  <link rel="shortcut icon" href="${path}/resource/favicon.ico">
  <style>
  	html{
  		height:100%;
  		width:100%;
  	}
  	body{
  		height:100%;
  		width:100%;
  	}
  	.top{
  		border:none;
  	}
  	
  </style>
</head>
<body style="background:url(${path}/resource/images/bg.jpg) no-repeat;position:relative;background-size: 100% 100%;">
<div class="wrapper">
	<div class="">
    	<header class="top-item">
            <div class="white ac"><img src="${path}/resource/images/top_login_text.png"/></div>
        </header>
    </div>
    <!-- ./top -->
  	<div class="main-login">
    	<div class="main-login-box">
        	<div class="login-tit">
            	<div class="pull-left" style="margin: 12px 15px"><img src="${path}/resource/images/logo.png"/></div>
            </div>
            <div class="login-wrap">
            	<div class="row" style="padding: 0px 75px;">
                	<div class="col-xs-12" style="margin: 15px 0 5px">
                    	<h4>用户登录</h4>
                    </div><!----col-xs-12/E---->
                    <div class="col-xs-12" style="margin-bottom:15px;">
                    	<div class="row">
                        	<div class="col-xs-1">
                            	<div class="lft-bg"><img src="${path}/resource/images/icon_user.png"/></div>
                            </div>
                            <div class="col-xs-11">
                            	<input id="account" type="text" class="l-input" placeholder="用户名"/>
                            </div>
                        </div>
                    </div><!----col-xs-12/E---->
                    <div class="col-xs-12 mt30">
                    	<div class="row">
                        	<div class="col-xs-1">
                            	<div class="lft-bg"><img src="${path}/resource/images/icon_lock.png"/></div>
                            </div>
                            <div class="col-xs-11">
                            	<input id="password" type="password" class="l-input" placeholder="密    码"/>
                            </div>
                        </div>
                    </div><!----col-xs-12/E---->
                    <div class="col-xs-12 mt20 f16">
                    	<div class="ac" style="display: none;">
                    		<i class="icon-error"><img src="${path}/resource/images/error.png"/></i>&nbsp;&nbsp;
                    		<span class="black">用户名或密码不正确</span>
                    	</div>
                    	<!--  
                    	<div class="row">
                            <div class="col-xs-4">
                      		<input type="checkbox" class="l-check"/>
                                <span class="gray" style="position:relative;top:-5px;">记住密码</span>
                            </div>
                            <div class="col-xs-8">
                            	<ul class="sb-list pull-right">
                                	<li class="active"><a href="#">设备管理</a></li>
                                    <li><a href="#">设备监控</a></li>
                                </ul>
                            </div>
                        </div>
                        -->
                    </div><!----col-xs-12/E---->
                    <div class="col-xs-12 mt20">
                    </div>
                    <!----col-xs-12/E---->
               	</div><!----row/E---->
            </div><!---login-wrap---->
            <div class="login-btn">
                <a href="javascript:void(0)" onclick="login();" class="l-button ac">登录 </a>
            </div><!----login-btn/E---->
        </div>
    </div>
    <!-- ./main-login -->
</div>
<!-- ./wrapper -->
<div class="bottom">
  	<p class="ac white">2016 版权所有:中国株洲电力机车研究所有限公司</p>
</div>
<!-- ./bottom -->
<script src="${path}/resource/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script type="text/javascript">
	function login() {
		if ($("#account").val() == "") {
			alert('请输入账号！');
			return false;
		} else if ($("#password").val() == "") {
			alert('请输入密码！');
			return false;
		}
		$.ajax({
			type : 'POST',
			url : '<%=path%>/common/loginValue',
			//url : 'http://127.0.0.1:8081/airCondition-web/dataapi/loginCheck',
			data : {
				userName : $("#account").val(),
				userPass : $("#password").val()
			},
			dataType : 'json',
			async : false,
			success : function(data) {console.log(data);
				if(data.status == "OK") {
					//alert(data.status+"----"+data.url);
					window.location.href = "<%=path%>/"+ data.url;
				} else if(data.status == "FAIL") {
					$('.ac').show();
				} else {
					//window.location.href = data.url;
					window.location.href = "<%=path%>/common/redirect/exhibition";
				}
			},
			error : function() {
				alert("系统错误！");
			}
		})
	}
	$(function() {
		//调整登录框位置
		var loginh = $('.main-login')[0].clientHeight;
		var allHeight = document.documentElement.clientHeight - 75;
		var loginmartop = allHeight/2 - loginh/2;
		$('.main-login').css('margin-top',loginmartop);
	})
	
	window.onkeydown = function(e) {
		if(e.keyCode == 13) {
			login();
		}
	}
</script>
</body>
</html>
